﻿using System;
using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Input;
using System.Windows.Media.Animation;
using System.Diagnostics;
using Shapes = System.Windows.Shapes;

namespace GemBlaster.UI
{
    public class GemBlasterSplash : Control
    {
        public GemBlasterSplash()
        {
            Stream s = this.GetType().Assembly.GetManifestResourceStream("GemBlaster.UI.GemBlasterSplash.xaml");
            FrameworkElement Root = this.InitializeFromXaml(new StreamReader(s).ReadToEnd());

            Shapes.Path Play = Root.FindName("PlayButtonGlass") as Shapes.Path;
            Shapes.Path Info = Root.FindName("InfoButtonGlass") as Shapes.Path;

            Storyboard PlayHover = Root.FindName("PlayButtonHover") as Storyboard;
            Storyboard InfoHover = Root.FindName("InfoButtonHover") as Storyboard;

            Play.MouseEnter += delegate(object sender, MouseEventArgs e)
            {
                PlayHover.Begin();
            };

            Play.MouseLeave += delegate(object sender, EventArgs e)
            {
                PlayHover.Stop();
            };

            Info.MouseEnter += delegate(object sender, MouseEventArgs e)
            {
                InfoHover.Begin();
            };

            Info.MouseLeave += delegate(object sender, EventArgs e)
            {
                InfoHover.Stop();
            };

            Play.MouseLeftButtonDown += delegate(object sender, MouseEventArgs e)
            {
                if (PlayGame != null)
                {
                    PlayGame(this, EventArgs.Empty);
                }
            };

            Info.MouseLeftButtonDown += delegate(object sender, MouseEventArgs e)
            {
                if (GameInfo != null)
                {
                    GameInfo(this, EventArgs.Empty);
                }
            };
        }


        public event EventHandler PlayGame;

        public event EventHandler GameInfo;
    }
}